/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "require")
@NamedQueries({
    @NamedQuery(name = "Require.findAll", query = "SELECT r FROM Require r"),
    @NamedQuery(name = "Require.findByRId", query = "SELECT r FROM Require r WHERE r.rId = :rId"),
    @NamedQuery(name = "Require.findByRName", query = "SELECT r FROM Require r WHERE r.rName = :rName"),
    @NamedQuery(name = "Require.findByRDescription", query = "SELECT r FROM Require r WHERE r.rDescription = :rDescription")})
public class Require implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "r_id")
    private Integer rId;
    @Basic(optional = false)
    @Column(name = "r_name")
    private String rName;
    @Column(name = "r_description")
    private String rDescription;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "require", fetch = FetchType.LAZY)
    private List<RequireItem> requireItemList;
    @JoinColumn(name = "p_id", referencedColumnName = "p_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Project project;

    public Require() {
    }

    public Require(Integer rId) {
        this.rId = rId;
    }

    public Require(Integer rId, String rName) {
        this.rId = rId;
        this.rName = rName;
    }

    public Integer getRId() {
        return rId;
    }

    public void setRId(Integer rId) {
        this.rId = rId;
    }

    public String getRName() {
        return rName;
    }

    public void setRName(String rName) {
        this.rName = rName;
    }

    public String getRDescription() {
        return rDescription;
    }

    public void setRDescription(String rDescription) {
        this.rDescription = rDescription;
    }

    public List<RequireItem> getRequireItemList() {
        return requireItemList;
    }

    public void setRequireItemList(List<RequireItem> requireItemList) {
        this.requireItemList = requireItemList;
    }

    public Project getProject() {
        return project;
    }

    public void setProject(Project project) {
        this.project = project;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (rId != null ? rId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Require)) {
            return false;
        }
        Require other = (Require) object;
        if ((this.rId == null && other.rId != null) || (this.rId != null && !this.rId.equals(other.rId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.Require[rId=" + rId + "]";
    }

}
